#ifndef _REGISTRYMANAGER_H
#define _REGISTRYMANAGER_H

/******************************************************************************
** @file	RegistryManager.h
** @author	Arturo Aguilar Tapia
**
** @date	Jul 22, 2010
**
** @desc	This class is created for load registrys from especific root and especific subKey 
**			this class contains methods that manipulate system registry keys and values
**			This class using StdRegProv Class and using EnumKey and EnumValues methods
**			for more documentation about StdRegProv visit http://msdn.microsoft.com/en-us/library/aa393664(VS.85).aspx
**
**			You can use the methods to perform the following tasks:
**
**			-Enumerate, registry keys.
**			-Enumerate, named values.
**			
**
******************************************************************************/

#include <comdef.h>
#include <Wbemidl.h>
#include <string>
#include "WMIConnection.h"
#include "WRegistry.h"
#include "WConstants.h"
#include <log4cxx\logger.h>
#include <log4cxx\xml\domconfigurator.h>

class RegistryManager
{
public:
	/**
	* Constructor of RegistryManager
	*
	* @param WMIConnection, it's a necesari Connection to execute methods of manager	
	*/
	RegistryManager(WMIConnection* con);
	~RegistryManager(void);

	/**
	* getRegistrys Method Insert all Registry into rClass WRegistry param from especific root and especific SubKey
	*
	* @param root, it's a HiveEnum it represents a Hive of the registry for example HKEY_CLASSES_ROOT
	* @param subKey, a wstring that represents a subKey of the resgitry 
	* @param WRegistry is a registry class to load registry in this class
	*/
	WHResult*
	getRegistrys(HiveEnum root,wstring SubKey,WRegistry** rClass);

	/**
	* getRegistrys Method Overload
	*
	* @param WRegistry is a registry class to load registry in this class
	*/
	WHResult*
	getRegistrys(WRegistry** rClass);

	/**
	* LoadMethod Load Values into rClass return tru if the rClass contains Values
	*
	* @param rClass is a WRegistry class to load registry in this class
	*/
	WHResult*
	LoadValues(WRegistry** rClass);

	void
	getStandardRegistryHives(vector<WRegistry>& standarRegistrys);

private:

	/**
	* Necesary Connection for execute methods from StrRegProv Class
	*/
	WMIConnection* _con;

	/**
	* _pClass IWebemClassObject contains an instance of StrRegProv Class
	*/
	IWbemClassObject*_pClass;

	/**
	* _ClassName BSTR contains the name of StrRegProv Class
	*/
	BSTR _ClassName;

	/**
	* getMethod is a Method for return IWbemClassObject contains StrRegProv instance
	* and this istance is returned into pOutParam outputParam
	*
	* @param root, it's a HiveEnum it represents a Hive of the registry for example HKEY_CLASSES_ROOT
	* @param subKey, a wstring that represents a subKey of the resgitry 
	* @param NameMethod, a wchar_t* that represents the name of method present into StrRegProv example(EnumKey,EnumValues)
	* @param pOutParam is a IWemClassObject** output param is a class to load registry into this class
	* @param ValueName is optional wstring represent especific Name of Value for find Value
	*/
	WHResult* 
	getMethod(HiveEnum root,wstring subKey,wstring nameMethod,IWbemClassObject** pOutParams,wstring ValueName);

	/**
	* getStringValue Method Return Value of especific Registry Value
	*
	* @param root, it's a HiveEnum it represents a Hive of the registry for example HKEY_CLASSES_ROOT
	* @param subKey, a wstring that represents a subKey of the resgitry 
	* @param valueName is a wstring that represent name of Value a to evaluate
	* @param valueString is a wstring output  param contains StringValue of Value
	*/
	WHResult* 
	getStringValue(HiveEnum root,wstring subKey,wstring valueName,wstring valueString);

	int 
	getParseRoot(wstring path, wstring& root,wstring& subKey);

	HiveEnum 
	convertStringToHKEY(wstring strKey);

	wstring
	convertHiveEnumToWstring(HiveEnum hive);

};
#endif